package com.yyw.rabbitmq.core.config;

import org.springframework.stereotype.Component;

import java.util.concurrent.*;

/**
 * 异步线程池
 */
@Component
public class AsyncConfig {

    private final static int size = 1000;

    /*  创建一个异步队列    */
    public static ExecutorService executor = new ThreadPoolExecutor(size, size, 60L,
            TimeUnit.SECONDS,
            new LinkedBlockingQueue<>(size),
            Executors.defaultThreadFactory(),
            new ThreadPoolExecutor.AbortPolicy());

    /*  异步队列的提交     */
    public static void submit(Runnable runnable) {
        executor.submit(runnable);
    }
}
